Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix promptForBoolean to display the default initial value capitalized #1829

Merged
merged 2 commits into from
May 9, 2024

Conversation

rebeccahum
Copy link
Contributor

@rebeccahum rebeccahum commented May 9, 2024

Description

We should be passing in a boolean value into the initial property for Confirm(): https://github.com/enquirer/enquirer/blob/70bdb0fedc3ed355d9d8fe4f00ac9b3874f94f61/lib/prompts/confirm.js#L8
However, since we convert it to a string, it will always evaluate to true and display Y/n for everything:

initial: initial.toString(),

This is because ConfirmQuestionOptions expects a string for initial (it inherits from

initial?: T | ( () => Promise< T > | T );
). Looks like we are using an experimental version of the types definitions @ enquirer/enquirer#307. Kind of hacky, but I think it's ok for now if we want to keep things in sync with the PR?

If we want to fix it in the Types definition, I think we need to change initial?: T | ( () => Promise< T > | T ); to initial?: T | ( () => Promise< T > | T ) | boolean | ( () => Promise< boolean > | boolean ); under export type Question< T extends types.Answer = string, P extends Prompt< T > = Prompt< T > > = {
^ Happy to go about this way too and leave a comment in the PR

Pull request checklist

New release checklist

Steps to Test

Outline the steps to test and verify the PR here.

Example:

  1. Check out PR.
  2. Run npm run build
  3. Do vip dev-env create and expect to display as Enable Elasticsearch (needed by Enterprise Search)? (y/N)

@rebeccahum rebeccahum requested a review from sjinks May 9, 2024 14:03
Copy link
Contributor

github-actions bot commented May 9, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

Copy link

sonarqubecloud bot commented May 9, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@rebeccahum rebeccahum merged commit 3845404 into trunk May 9, 2024
17 checks passed
@rebeccahum rebeccahum deleted the fix/boolean-prompt-capitalization branch May 9, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants